package com.itheima.BrandTest;


import com.itheima.Config.SpringConfig;
import com.itheima.mapper.Btrandmapper;
import com.itheima.pojo.Brand;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SpringConfig.class})
public class test{
    @Autowired
    private Btrandmapper brandmapper;
    @Test
    //添加
    public void tianjia(){
        Brand brand = new Brand();
        brand.setId(1);
        brand.setName("huangjiaju");
        brand.setHobby("sing");
        int add = brandmapper.add(brand);
        System.out.println(add);
    }
    //查询
    @Test
    public void findtest() {
        List<Brand> findall = brandmapper.findall();
        for (Brand brand : findall) {
            System.out.println(brand);
        }
    }
    //删除
    @Test
    public void deletetest() {
        int i = brandmapper.deleteById(1);
        System.out.println(i);
    }
    //删除
    @Test
    public void shanchu() {
        Brand brand = new Brand();
        brand.setName("libai");
        brand.setHobby("youyong");
        brand.setId(6);
        brandmapper.updateUser(brand);
    }
}
